package classUtils;

/**
 * @program: pangu
 * @description:
 * @author: fengjd
 * @create: 2022-06-23 09:05
 **/
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//


import co.elastic.clients.json.JsonData;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Function;
import javax.annotation.Nullable;

@JsonpDeserializable
public class User {
    @Nullable
    private String email;
    @Nullable
    private String fullName;
    private Map<String, JsonData> metadata;
    private List<String> roles;
    private String username;
    private boolean enabled;


    public static co.elastic.clients.elasticsearch.security.User userOf(Function<co.elastic.clients.elasticsearch.security.User.Builder, ObjectBuilder<co.elastic.clients.elasticsearch.security.User>> fn) {
        return (co.elastic.clients.elasticsearch.security.User) ((ObjectBuilder) fn.apply(new co.elastic.clients.elasticsearch.security.User.Builder())).build();
    }

    @Nullable
    public final String email() {
        return this.email;
    }

    @Nullable
    public final String fullName() {
        return this.fullName;
    }

    public final Map<String, JsonData> metadata() {
        return this.metadata;
    }

    public final List<String> roles() {
        return this.roles;
    }

    public final String username() {
        return this.username;
    }

    public final boolean enabled() {
        return this.enabled;
    }


    protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
        if (this.email != null) {
            generator.writeKey("email");
            generator.write(this.email);
        }

        if (this.fullName != null) {
            generator.writeKey("full_name");
            generator.write(this.fullName);
        }

        Iterator var3;
        if (ApiTypeHelper.isDefined(this.metadata)) {
            generator.writeKey("metadata");
            generator.writeStartObject();
            var3 = this.metadata.entrySet().iterator();

            while (var3.hasNext()) {
                Entry<String, JsonData> item0 = (Entry) var3.next();
                generator.writeKey((String) item0.getKey());
                ((JsonData) item0.getValue()).serialize(generator, mapper);
            }

            generator.writeEnd();
        }

        if (ApiTypeHelper.isDefined(this.roles)) {
            generator.writeKey("roles");
            generator.writeStartArray();
            var3 = this.roles.iterator();

            while (var3.hasNext()) {
                String item0 = (String) var3.next();
                generator.write(item0);
            }

            generator.writeEnd();
        }

        generator.writeKey("username");
        generator.write(this.username);
        generator.writeKey("enabled");
        generator.write(this.enabled);
    }




}

